package com.imarec.web.persistence.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.projektio.io.ImageAttribute;

@Entity
@Table(name="ATTRIBUTES")
public class ImageAttributeEntity 
{
	@Id
	@Column(name="ATTRIBUTE_ID")
	@GeneratedValue(strategy=GenerationType.AUTO)
	private long id;
	
	@Column(name="BLACK_COUNT", nullable=false)
	private int blackCount;
	@Column(name="WHITE_COUNT", nullable=false)
	private int whiteCount;
	
	@Column(name="ROW_INDEX", nullable=false)
	private int row;
	@Column(name="COLUMN_INDEX", nullable=false)
	private int column;
	
	@Column(name="RED_COLOR", nullable=false)
	private int redColor;
	@Column(name="GREEN_COLOR", nullable=false)
	private int greenColor;
	@Column(name="BLUE_COLOR", nullable=false)
	private int blueColor;
	
	@ManyToOne
	@JoinColumn(name="IMAGE_ID", referencedColumnName="IMAGE_ID")
	private ImageEntity image;

	public ImageAttributeEntity()
	{
		
	}
	
	public ImageAttributeEntity(ImageAttribute attribute)
	{
		this.row = attribute.getRow();
		this.column = attribute.getColumn();
		
		this.blackCount = attribute.getBlackPixels();
		this.whiteCount = attribute.getWhitePixels();
		
		this.redColor = attribute.getColor()[0];
		this.greenColor = attribute.getColor()[1];
		this.blueColor = attribute.getColor()[2];
	}
	
	public long getId()
	{
		return id;
	}

	public void setId(long id)
	{
		this.id = id;
	}

	public void setBlackCount(int blackCount) 
	{
		this.blackCount = blackCount;
	}

	public int getBlackCount() 
	{
		return blackCount;
	}

	public void setWhiteCount(int whiteCount) 
	{
		this.whiteCount = whiteCount;
	}

	public int getWhiteCount() 
	{
		return whiteCount;
	}

	public void setRow(int row)
	{
		this.row = row;
	}

	public int getRow() 
	{
		return row;
	}

	public void setColumn(int column)
	{
		this.column = column;
	}

	public int getColumn()
	{
		return column;
	}

	public void setImage(ImageEntity image) 
	{
		this.image = image;
	}

	public ImageEntity getImage() 
	{
		return image;
	}

	public void setRedColor(int redColor) 
	{
		this.redColor = redColor;
	}

	public int getRedColor() 
	{
		return redColor;
	}

	public void setGreenColor(int greenColor)
	{
		this.greenColor = greenColor;
	}

	public int getGreenColor() 
	{
		return greenColor;
	}

	public void setBlueColor(int blueColor) 
	{
		this.blueColor = blueColor;
	}

	public int getBlueColor() 
	{
		return blueColor;
	}
}
